package de.bastian.hinterleitner.adaptersviews;

import java.util.List;

import de.bastian.hinterleitner.tools.Constants;
import de.hijacksoft.wyc.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class CurrencyAdapter extends ArrayAdapter<String> {

	private Context context;

	public CurrencyAdapter(Context c, List<String> currencies) {
		super(c, android.R.layout.simple_spinner_item, currencies);
		context = c;
	}

	@Override
	public View getDropDownView(int position, View convertView, ViewGroup parent) {
		if(convertView == null){
			LayoutInflater inflator = (LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = inflator.inflate(android.R.layout.simple_spinner_dropdown_item, null);
		}
		
		TextView text = (TextView)convertView.findViewById(android.R.id.text1);
		
		String unit = Constants.getUnits(context).get(position);
		String unitname = Constants.getUnitNames(context).get(position);
		
		text.setText(unit+"\t"+unitname);

		return convertView;
	}
	
}
